package com.gaoshu.controller;

import com.gaoshu.bean.DoctorDuibi;
import com.gaoshu.bean.Finance;
import com.gaoshu.service.TongJiService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("TongJi")
public class TongJiController {
    @Autowired
    private TongJiService tongjiservice;
    /**
     * 门诊月度统计!
     */
    @ResponseBody
    @RequestMapping("SelectReportAndCaishier.do")
    public Object SelectReportAndCaishier(String year) {
        List<Double> src = tongjiservice.SelectReportAndCaishier(year);
        for (int i = 0; i < src.size(); i++) {
            if (src.get(i) == null) {
                src.set(i, 0.0);
            }
        }
        return src;
    }
    /**
     * 住院月度统计!
     */
    @ResponseBody
    @RequestMapping("SelectRegister.do")
    public Object SelectRegister(String year){
       List<Double> sr=tongjiservice.SelectRegister(year);
       for(int i=0;i<sr.size();i++){
           if(sr.get(i)==null){
               sr.set(i,0.0);
           }
       }
       return sr;
    }
    /**
     * 门诊年度统计!
     */
    @ResponseBody
    @RequestMapping("SelectReportAndFinance.do")
    public Object SelectReportAndFinance(){
       List<Finance> srf=tongjiservice.SelectReportAndFinanace();
       return srf;
    }

    /**
     * 住院年度统计！
     * @return
     */
    @ResponseBody
    @RequestMapping("SelectRegisterFinance.do")
    public Object SelectRegisterFinance(){
      List<Finance> rf=tongjiservice.SelectRegisterFinance();
      return rf;
    }

    /**
     * 门诊医生统计对比
     */
    @ResponseBody
    @RequestMapping("SelectMDoctor.do")
    public Object SelectMDoctor(DoctorDuibi doctorDuibi,Integer page,Integer limit){
       List<DoctorDuibi> smd=tongjiservice.SelectMDoctor(doctorDuibi);
        PageInfo pageinfo=new PageInfo(smd);
        Map<String, Object> tableData = new HashMap<String, Object>();
        tableData.put("code", 0);
        tableData.put("msg", "");
        tableData.put("count", pageinfo.getTotal());
        tableData.put("data", pageinfo.getList());
        return tableData;
    }
    /**
     * 住院医生统计对比
     */
    @ResponseBody
    @RequestMapping("SelectZDoctor.do")
    public Object SelectZDoctor(DoctorDuibi doctorDuibi,Integer page,Integer limit){
        List<DoctorDuibi> szd=tongjiservice.SelectZDoctor(doctorDuibi);
        PageInfo pageinfo=new PageInfo(szd);
        Map<String, Object> tableData = new HashMap<String, Object>();
        tableData.put("code", 0);
        tableData.put("msg", "");
        tableData.put("count", pageinfo.getTotal());
        tableData.put("data", pageinfo.getList());
        return tableData;
    }
    /**
     * 门诊当天统计
     */
    @ResponseBody
    @RequestMapping("SelectCaishier.do")
    public Object SelectCaishier(String current){
       List<Finance> sc=tongjiservice.SelectCaishier(current);
       return sc;
    }
}
